<?php
	require_once('bootstrap.php');
	
	global $db;
	$query = $db->db_query('DROP TABLE dbusers');
	$db->execute($query);
	
	$query = $db->db_query('DROP TABLE userconfig');
	$db->execute($query);
	
	$query = $db->db_query('DROP TABLE dbstats');
	$db->execute($query);
	
	$query = $db->db_query('CREATE TABLE dbusers(name varchar(50),
	pass varchar(50),
	role varchar(10),
	PRIMARY KEY  (name))');
	$db->execute($query);
	
	$query = $db->db_query('CREATE TABLE dbstats(
	TIME_STAMP timestamp,
	PCT_FREE_MEM decimal(10,2),
	DIC_HR decimal(10,2),
	PCT_RELOADS decimal(10,2),
	BUFFER_HR decimal(10, 2),
	REDO_WAIT_R decimal(10, 2),
	IMM_ALLOC decimal(10, 2),
	IMM_COPY decimal(10, 2),
	WAIT_ALLOC decimal(10, 2),
	WAIT_COPY decimal(10, 2),
	PCT_SORTS decimal(10, 2),
	ROLLBACK decimal(10, 2),
	PRIMARY KEY  (TIME_STAMP))');
	$db->execute($query);
	
	$query = $db->db_query('CREATE TABLE userconfig(name varchar(50),
	x int,
	y int,
	PCT_FREE_MEM decimal(10,2),
	DIC_HR decimal(10,2),
	PCT_RELOADS decimal(10,2),
	BUFFER_HR decimal(10, 2),
	REDO_WAIT_R decimal(10, 2),
	IMM_ALLOC decimal(10, 2),
	IMM_COPY decimal(10, 2),
	WAIT_ALLOC decimal(10, 2),
	WAIT_COPY decimal(10, 2),
	PCT_SORTS decimal(10, 2),
	ROLLBACK decimal(10, 2),
	PRIMARY KEY  (name))');
	$db->execute($query);
	
	$user = new User();
	$user->name = 'system';
	$user->pass = 'leoeric';
	$user->role = '1';
	$user->add();
	
	$userconfig = new UserConfig();
	$userconfig->name = 'system';
	$userconfig->para['x'] = 60;
	$userconfig->para['y'] = 15;
	$userconfig->para['PCT_FREE_MEM'] = 1;
	$userconfig->para['DIC_HR'] = 1;
	$userconfig->para['PCT_RELOADS'] = 1;
	$userconfig->para['BUFFER_HR'] = 1;
	$userconfig->para['REDO_WAIT_R'] = 1;
	$userconfig->para['IMM_ALLOC'] = 1;
	$userconfig->para['IMM_COPY'] = 1;
	$userconfig->para['WAIT_ALLOC'] = 1;
	$userconfig->para['WAIT_COPY'] = 1;
	$userconfig->para['PCT_SORTS'] = 1;
	$userconfig->para['ROLLBACK'] = 1;
	$userconfig->add();
	
	/*
	$dbstat = new DbStat();
	$dbstat->para['PCT_FREE_MEM'] = 1;
	$dbstat->para['DIC_HR'] = 1;
	$dbstat->para['PCT_RELOADS'] = 1;
	$dbstat->para['BUFFER_HR'] = 1;
	$dbstat->para['REDO_WAIT_R'] = 1;
	$dbstat->para['IMM_ALLOC'] = 1;
	$dbstat->para['IMM_COPY'] = 1;
	$dbstat->para['WAIT_ALLOC'] = 1;
	$dbstat->para['WAIT_COPY'] = 1;
	$dbstat->para['PCT_SORTS'] = 1;
	$dbstat->para['ROLLBACK'] = 1;
	$dbstat->add();
	*/
?>